package com.atgion.service.controller;

import com.atgion.service.service.UserAddressService;
import com.atgion.spzx.model.entity.user.UserAddress;
import com.atgion.spzx.model.vo.base.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "用户地址接口")
@RestController
@RequestMapping(value="/api/user/userAddress")
public class UserAddressController {

    @Autowired
    private UserAddressService userAddressService;

    @Operation(summary = "获取用户地址列表")
    @GetMapping("auth/findUserAddressList")
    public Result<List<UserAddress>> findUserAddressList() {
        List<UserAddress> list = userAddressService.findUserAddressList();
        return Result.success(list) ;
    }

//    远程调用 根据选中id获取 订单选中地址
    @Operation(summary = "获取地址信息")
    @GetMapping("/getUserAddress/{id}")
    public UserAddress getUserAddress(@Parameter(name = "id",  required = true)  @PathVariable Long id) {
//        简单的报错代码
        return userAddressService.getById(id);
    }


}